import java.util.Scanner;

public class VentasBarJavier {
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		float max=0;
		float min =0;
		int dia_max=0;
		int dia_min =0;
		boolean e_max=false;
		boolean e_min=false;
		float aux;
		float suma;
		aux = a.nextFloat();
		while(aux!=-1){
			//resetar Variables
			dia_max=0;
			dia_min =0;
			e_max=false;
			e_min=false;
			suma =aux;
			max =aux;
			min = aux;
			for(int i = 1; i<6; i++){
				aux = a.nextFloat();
				if(max==aux){
					e_max=true;
				}
				if(max<aux){
					max=aux;
					dia_max=i;
					e_max=false;
				
				}
				if(min==aux){
					e_min=true;
				}
				if(min>aux){
					min=aux;
					dia_min=i;
					e_min=false;
				
				}
				
				suma+=aux;
			}
			//imprimir salida
			imprimirDia(dia_max,e_max);
			imprimirDia(dia_min,e_min);
			imprimirMedia(suma,aux);
			aux = a.nextFloat();
			
	}
	}
	public static void imprimirDia(int i, boolean a){
		if(!a){
			switch (i) {
			case 0:
				System.out.print("MARTES ");
				break;
			case 1:
				System.out.print("MIERCOLES ");
				break;
			case 2:
				System.out.print("JUEVES ");
				break;
			case 3:
				System.out.print("VIERNES ");
				break;
			case 4:
				System.out.print("SABADO ");
				break;
			case 5:
				System.out.print("DOMINGO ");
				break;
			}
		}else
			System.out.print("EMPATE ");
	}
	public static void imprimirMedia(float suma, float domingo){
		suma= suma/6;
		if(suma>domingo)
			System.out.println("NO");
		else
			System.out.println("SI");
	}
}
